home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue41 / Clinic / TstPropU.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1998-10-13  |  1.2 KB  |  53 lines

  1. unit TstPropU;
  2.  
  3. interface
  4.  
  5. uses
  6.   WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ExtCtrls, DBCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Panel1: TPanel;
  12.     ComboBox1: TComboBox;
  13.     Button1: TButton;
  14.     DBNavigator1: TDBNavigator;
  15.     procedure Button1Click(Sender: TObject);
  16.   end;
  17.  
  18. var
  19.   Form1: TForm1;
  20.  
  21. implementation
  22.  
  23. {$R *.DFM}
  24.  
  25. uses
  26.   TypInfo;
  27.  
  28. function IsPropPublished(AClass: TClass;
  29.   const PropName: String): Boolean;
  30. begin
  31.   Result := GetPropInfo(AClass.ClassInfo, PropName) <> nil
  32. end;
  33.  
  34. procedure TForm1.Button1Click(Sender: TObject);
  35. const
  36.   MsgYes = '%s looks good';
  37.   MsgNoGood = '%s is not based on a TCustomPanel';
  38.   MsgNearly = '%s doesn''t have it published';
  39. var
  40.   Loop: Integer;
  41. begin
  42.   for Loop := 0 to Pred(ComponentCount) do
  43.     if Components[Loop] is TCustomPanel then
  44.       if IsPropPublished(Components[Loop].ClassType, 'BevelInner') then
  45.         ShowMessage(Format(MsgYes, [Components[Loop].Name]))
  46.       else
  47.         ShowMessage(Format(MsgNearly, [Components[Loop].Name]))
  48.     else
  49.       ShowMessage(Format(MsgNoGood, [Components[Loop].Name]))
  50. end;
  51.  
  52. end.
  53.